﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using EZCRS.HCMS.Entity;
using EZCRS.HCMS.SqlClient;


namespace EZCRS.HCMS.Bll.baseinfo
{
    public class Bllh_activelog
    {
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="page">当前页数</param>
        /// <param name="pagecount">总页数</param>
        /// <param name="swhere">查询条件</param>
        /// <returns></returns>
        public List<HCRS_Activelog> getallbypage(int page, out int pagecount, string swhere)
        {
            //查询条件
            string strwhere = swhere;

            return new sql_hcrs_activelog().getallbypage(page, strwhere, out pagecount);
        }

        /// <summary>
        /// 获得所有符合条件的记录
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public List<HCRS_Activelog> getitem(string search)
        {
            string sqlwhere = search;
            return new sql_hcrs_activelog().getall(sqlwhere);
        }

        /// <summary>
        /// 获得一条记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public HCRS_Activelog getitem(int id)
        {
            return new sql_hcrs_activelog().getitem(id);
        }

        #region 删除
        /// <summary>
        /// 删除一条记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool deleteitem(int id)
        {
            return new sql_hcrs_activelog().deleteitem(id);
        }

        /// <summary>
        /// 删除一系列数据
        /// </summary>
        /// <param name="idlist"></param>
        /// <returns></returns>
        public bool deleteitem(string idlist)
        {
            return new sql_hcrs_activelog().deleteitem(idlist);
        }
        #endregion

        public HCRS_Activelog getlastbypid(int pid)
        {
            return new sql_hcrs_activelog().getlastbypid(pid);
        }
        /// <summary>
        /// 添加或修改
        /// </summary>
        /// <param name="_log"></param>
        /// <returns></returns>
        public bool insertorupdateitem(HCRS_Activelog _log)
        {
            return new sql_hcrs_activelog().insertorupdate(_log);
        }

        /// <summary>
        /// 处理酒店状态
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="status"></param>
        /// <param name="remark"></param>
        /// <returns></returns>
        public bool changestatus(int pid, string status, string remark,int uid)
        {
            HCRS_Activelog _log = new HCRS_Activelog();
            _log.id = 0;
            _log.offdate = DateTime.Now;
            _log.offuid = uid;
            _log.status = status;
            _log.offremark = remark;
            _log.pid = pid;

            if (new sql_hcrs_activelog().insertorupdate(_log))
            {
                if (new sql_hcrs_hotel().updatestatus(pid, status))
                    return true;
                else
                    return false;
            }
            else
                return false;
        }

    }
}
